package com.ywu.bpmn.flow.api;

import com.ywu.bpmn.flow.dto.YwuFlowInstanceCommonDto;
import com.ywu.bpmn.flow.service.YwuFlowInstanceService;
import com.ywu.common.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName YwuFlowInstanceApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2025/4/23 14:58
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/bpmn/flow/instance")
public class YwuFlowInstanceApi {

    @Autowired
    private YwuFlowInstanceService service;

    /**
    * @Author GroundDemo
    * @Description 查询代办的流程列表
    * @Date 15:45 2025/4/23
    * @Param [dto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/flowTodoList")
    public CommonResult<Object> flowTodoList(@RequestBody YwuFlowInstanceCommonDto dto) {
        return service.flowTodoList(dto);
    }

    /**
    * @Author GroundDemo
    * @Description 流程实例代办列表
    * @Date 16:00 2025/4/23
    * @Param [dto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/instanceTodoList")
    public CommonResult<Object> instanceTodoList(@RequestBody YwuFlowInstanceCommonDto dto) {
        return service.instanceTodoList(dto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询流程实例详情，包括表单构建Json、流程构建JSON，表单实例数据
    * @Date 22:59 2025/4/23
    * @Param [dto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/instanceDetailInfo")
    public CommonResult<Object> queryInstanceDetailInfo(@RequestBody YwuFlowInstanceCommonDto dto) {
        return service.queryInstanceDetailInfo(dto);
    }

    /**
    * @Author GroundDemo
    * @Description 审批流程
    * @Date 10:53 2025/4/24
    * @Param [dto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/completeInstance")
    public CommonResult<Object> completeInstance(@RequestBody YwuFlowInstanceCommonDto dto) {
        return service.completeInstance(dto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询审批历史流程列表
    * @Date 20:31 2025/4/24
    * @Param [dto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/queryCompleteHistoryFlowList")
    public CommonResult<Object> queryCompleteHistoryFlowList(@RequestBody YwuFlowInstanceCommonDto dto) {
        return service.queryCompleteHistoryFlowList(dto);
    }

    /**
    * @Author GroundDemo
    * @Description 发起流程
    * @Date 18:05 2025/4/23
    * @Param [dto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/start")
    public CommonResult<Object> startInstance(@RequestBody YwuFlowInstanceCommonDto dto) {
        // 发起流程
        return service.startInstance(dto);
    }
}
